$(document).ready(function($) {
	(function($) {
	$.oValidate = function(id) {
		var list = {
		};
		if(id&&list[id]&&$('#'+id)) {
			$('#'+id).validate(list[id]);
		}else if(id&&$('#'+id)){
			$('#'+id).validate({});
		}
	};
	
})(jQuery);
		jQuery.validator.addMethod("byteRangeLength", function(value, element, param) {      
		  var length = value.length;      
		  for(var i = 0; i < value.length; i++){      
		      if(value.charCodeAt(i) > 127){      
		      length++;      
		      }      
		  } 
		  return this.optional(element) || ( length >= param[0] && length <= param[1] );      
		}, tip_length_rang); 
		
		jQuery.validator.addMethod("notDigit", function(value, element, param) {
				var patrn=/^[0-9]{1,20}$/; 
				if(patrn.test(value))   return false; 
				return true; 
			}, tip_not_all_digit); 

		jQuery.validator.addMethod("pzrequired", function(value, element, param) {
				//console.log('isInputEmpty'+isInputEmpty($(element)));
				if(isInputEmpty($(element)))   return false; 
				return true; 
			}, tip_required);
		
		jQuery.validator.setDefaults({
			    errorPlacement: function(error, placement) {
			      $(placement).attr('data-original-title',error.text());
			      $(placement).tooltip({
			         title: error.text(),
			         placement: 'top',
			         template: '<div class="tooltip"><div class="tooltip-error-arrow"></div><div class="tooltip-inner error-tip"></div></div>',
			         trigger:'manual'
			      });
			      $(placement).tooltip('show');
			      $(placement).bind('keydown',function(){$(placement).tooltip('hide');});
			   },
			   onkeyup: false,
			   focusInvalid: false,
			   submitHandler : function(form) {
				   $(form).find('[placeholder]').each(function() {
				        var input = $(this);
				        if (input.val() == input.attr('placeholder')) {
				            input.val('');
				        }
				      });
					$(form).ajaxSubmit({
							url : $(form).attr('action'),
							type : 'POST',
							dataType : 'json',
							beforeSubmit: function(){
								$('.submit-btn').button('loading');
							},
							success: function(result) {
								$('.submit-btn').button('reset');
								if (result.success === !0) {
									show_message('success',result.message,true,1000);
									setTimeout(function(){
										if(result.data&&result.data.url){
											window.location.href = result.data.url;
										}else if(result.data&&result.data.jsfunc){
											eval(result.data.jsfunc)(result);
										}else{
											window.location.reload();
										}
									},1000);
									return true;
								} else {
									showError(result.message);
									return false;
								}
							},
							error:function(data){
								checkredirect(data);
								$('.submit-btn').button('reset');
							}
					});
					return false;
				}
			});
		
});